import java.util.HashSet;
import java.util.Set;

public class TestDemo1 {
    public static void main(String[] args) {
        int len = lengthOfLongestSubstring("abcabcbb");
        System.out.println(len);
    }
    public static int lengthOfLongestSubstring(String s) {
        int max = 0;
        for(int i = 0; i < s.length(); i++){
            max = Math.max(getLength(s,i),max);
        }
        return max;
    }
    public static int getLength(String s,int len){
        Set<Character> set = new HashSet<>();
        while(len < s.length()){
            if(!set.add(s.charAt(len))){
                len++;
            }else{
                break;
            }
        }
        return set.size();
    }
}
